package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.AnswerForm;
import com.springboot.cloud.demos.ribbon.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class AnswerController {

    @Autowired
    private AnswerService answerService;

    @GetMapping("/answer")
    public Result query(@RequestParam("questionId") String questionId) {
        return answerService.query(questionId);
    }
    @GetMapping("/answer/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return answerService.get(id);
    }
    @PostMapping("/answer")
    public Result add(@RequestBody AnswerForm answerForm) {
        return answerService.save(answerForm);
    }

    @PutMapping(value = "/answer")
    public Result update(@RequestBody AnswerForm answerForm) {
        return answerService.update(answerForm);
    }
}
